package com.interceptor;

import com.po.User;
import org.springframework.boot.autoconfigure.kafka.KafkaProperties;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class LoginInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        User u= (User) request.getSession().getAttribute("user");
//        User a=(User) request.getSession().getAttribute("admin");

        if(u==null){
            response.sendRedirect("/login");
            return false;
        }
        return true;
    }

}
